package cn.stylefeng.guns.modular.nameNumebr.controller;

import cn.stylefeng.guns.modular.nameNumebr.pojo.request.NameNumberRequest;
import cn.stylefeng.guns.modular.nameNumebr.service.NameNumberService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 控制器
 *
 * @author jizhongbao
 * @date 2022/03/08 14:51
 */
@RestController
@ApiResource(name = "")
public class NameNumberController {

    @Resource
    private NameNumberService nameNumberService;

    /**
     * 添加
     *
     * @author jizhongbao
     * @date 2022/03/08 14:51
     */
    @PostResource(name = "添加", path = "/nameNumber/add")
    public ResponseData add(@RequestBody @Validated(NameNumberRequest.add.class) NameNumberRequest nameNumberRequest) {
        nameNumberService.add(nameNumberRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author jizhongbao
     * @date 2022/03/08 14:51
     */
    @PostResource(name = "删除", path = "/nameNumber/delete")
    public ResponseData delete(@RequestBody @Validated(NameNumberRequest.delete.class) NameNumberRequest nameNumberRequest) {
        nameNumberService.del(nameNumberRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author jizhongbao
     * @date 2022/03/08 14:51
     */
    @PostResource(name = "编辑", path = "/nameNumber/edit")
    public ResponseData edit(@RequestBody @Validated(NameNumberRequest.edit.class) NameNumberRequest nameNumberRequest) {
        nameNumberService.edit(nameNumberRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author jizhongbao
     * @date 2022/03/08 14:51
     */
    @GetResource(name = "查看详情", path = "/nameNumber/detail")
    public ResponseData detail(@Validated(NameNumberRequest.detail.class) NameNumberRequest nameNumberRequest) {
        return new SuccessResponseData(nameNumberService.detail(nameNumberRequest));
    }

    /**
     * 获取列表
     *
     * @author jizhongbao
     * @date 2022/03/08 14:51
     */
    @GetResource(name = "获取列表", path = "/nameNumber/list")
    public ResponseData list(NameNumberRequest nameNumberRequest) {
        return new SuccessResponseData(nameNumberService.findList(nameNumberRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author jizhongbao
     * @date 2022/03/08 14:51
     */
    @GetResource(name = "分页查询", path = "/nameNumber/page")
    public ResponseData page(NameNumberRequest nameNumberRequest) {
        return new SuccessResponseData(nameNumberService.findPage(nameNumberRequest));
    }

}